package org.springframework.aop.aspectj;

import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;

/**
 * @Name AspectJExpressionPointcutAdvisor
 * @Description: 基于 AspectJ 切点表达式的增强器 [实现] 类
 * @Version v1.0.0
 * @Author: lichao
 * @Date: 2024-03-28 14:52:02
 **/
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {
    private AspectJExpressionPointcut pointcut;
    private Advice advice;
    private String expression;

    public void setExpression(String expression) {
        this.expression = expression;
    }

    public void setAdvice(Advice advice) {
        this.advice = advice;
    }

    @Override
    public Pointcut getPointcut() {
        if (pointcut == null) pointcut = new AspectJExpressionPointcut(expression);
        return pointcut;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

}

